#ifndef CJSON_TYPE_H
#define CJSON_TYPE_H

#ifndef __cplusplus
#ifndef bool
#define bool _Bool   //should support c99
#define true 1
#define false 0
#endif
#endif

#define INIT_SIZE 10
#define INCREASE_SIZE 10
#define BUF_SIZE 2048

typedef char *ljsonc_key;
typedef char *CString;
typedef struct ljsonc_value ljsonc_value;
typedef struct ljsonc_element ljsonc_element;
typedef struct ljsonc_json ljsonc_json;
typedef struct ljsonc_array ljsonc_array;

typedef enum ljsonc_value_t {
    CJSON_VALUE_INT, CJSON_VALUE_DOUBLE, CJSON_VALUE_STRING, 
    CJSON_VALUE_JSON, CJSON_VALUE_ARRAY, CJSON_VALUE_COUNT
}ljsonc_value_t;

struct ljsonc_value {
    ljsonc_value_t valuetype;
    union {
        int int_value;
        double df_value;
        CString str_value;
        ljsonc_json *json_value;
        ljsonc_array *array_value;
    }value;
};

struct ljsonc_element {
    CString key;
    ljsonc_value *value;
};

struct ljsonc_json {
    int size;
    int capacity;
    ljsonc_element **values;    
};

struct ljsonc_array {
    int size;
    int capacity;
    ljsonc_value **values;   
};

#endif